home *** CD-ROM | disk | FTP | other *** search
/ Java Programmer's Toolkit / Java Programmer's Toolkit.iso / solaris2 / jdk / src / java / awt / image / imagecon.jav < prev    next >
Encoding:
Text File  |  1995-10-30  |  7.0 KB  |  182 lines

  1. /*
  2.  * @(#)ImageConsumer.java    1.8 95/08/29 Jim Graham
  3.  *
  4.  * Copyright (c) 1994 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software
  7.  * and its documentation for NON-COMMERCIAL purposes and without
  8.  * fee is hereby granted provided that this copyright notice
  9.  * appears in all copies. Please refer to the file "copyright.html"
  10.  * for further important copyright and licensing information.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  13.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  14.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  15.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  16.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  17.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  18.  */
  19.  
  20. package java.awt.image;
  21.  
  22. import java.util.Hashtable;
  23.  
  24. /**
  25.  * The interface for objects expressing interest in image data through
  26.  * the ImageProducer interfaces.  When a consumer is added to an image
  27.  * producer, the producer will deliver all of the data about the image
  28.  * using the method calls defined in this interface.
  29.  *
  30.  * @see ImageProducer
  31.  *
  32.  * @version    1.8 08/29/95
  33.  * @author     Jim Graham
  34.  */
  35. public interface ImageConsumer {
  36.     /**
  37.      * The dimensions of the source image are reported using the
  38.      * setDimensions method call.
  39.      */
  40.     void setDimensions(int width, int height);
  41.  
  42.     /**
  43.      * The extensible list of properties associated with this image.
  44.      */
  45.     void setProperties(Hashtable props);
  46.  
  47.     /**
  48.      * The ColorModel object which will be used for the majority of
  49.      * the pixels that will be reported using the setPixels method
  50.      * calls.  Note that each set of pixels delivered using setPixels
  51.      * contains its own ColorModel object, so no assumption should
  52.      * be made that this model will be the only one used in delivering
  53.      * pixel values.  A notable case where multiple ColorModel objects
  54.      * may be seen is when looking at a filtered image when the filter
  55.      * determines for each set of pixels that it filters whether the
  56.      * pixels can be sent on untouched, using the original ColorModel,
  57.      * or whether the pixels should be modified (filtered) and passed
  58.      * on using a ColorModel more convenient for the filtering process.
  59.      * @see ColorModel
  60.      */
  61.     void setColorModel(ColorModel model);
  62.  
  63.     /**
  64.      * The ImageProducer can deliver the pixels in any order, but
  65.      * the ImageConsumer may be able to scale or convert the pixels
  66.      * to the destination ColorModel more efficiently or with higher
  67.      * quality if it knows some information about how the pixels will
  68.      * be delivered up front.  The setHints method should be called
  69.      * before any calls to any of the setPixels methods with a bit mask
  70.      * of hints about the manner in which the pixels will be delivered.
  71.      * If the ImageProducer does not follow the guidelines for the
  72.      * indicated hint, then the results are undefined.
  73.      */
  74.     void setHints(int hintflags);
  75.  
  76.     /**
  77.      * The pixels will be delivered in a random order.  This tells the
  78.      * ImageConsumer not to use any optimizations that depend on the
  79.      * order of pixel delivery, which should be the default assumption
  80.      * in the absence of any call to the setHints method.
  81.      * @see #setHints
  82.      */
  83.     int RANDOMPIXELORDER = 1;
  84.  
  85.     /**
  86.      * The pixels will be delivered in top-down, left-to-right order.
  87.      * @see #setHints
  88.      */
  89.     int TOPDOWNLEFTRIGHT = 2;
  90.  
  91.     /**
  92.      * The pixels will be delivered in (multiples of) complete scanlines
  93.      * at a time.
  94.      * @see #setHints
  95.      */
  96.     int COMPLETESCANLINES = 4;
  97.  
  98.     /**
  99.      * The pixels will be delivered in a single pass.  Each pixel will
  100.      * appear in only one call to any of the setPixels methods.  An
  101.      * example of an image format which does not meet this criteria
  102.      * is a progressive JPEG image which defines pixels in multiple
  103.      * passes, each more refined than the previous.
  104.      * @see #setHints
  105.      */
  106.     int SINGLEPASS = 8;
  107.  
  108.     /**
  109.      * The image contain a single static image.  The pixels will be defined
  110.      * in calls to the setPixels methods and then the imageComplete method
  111.      * will be called with the STATICIMAGEDONE flag after which no more
  112.      * image data will be delivered.  An example of an image type which
  113.      * would not meet this criteria would be the output of a video feed,
  114.      * or the representation of a 3D rendering which is being manipulated
  115.      * by the user.  The end of each frame in those types of images will
  116.      * be indicated by calling imageComplete with the SINGLEFRAMEDONE flag.
  117.      * @see #setHints
  118.      * @see #imageComplete
  119.      */
  120.     int SINGLEFRAME = 16;
  121.  
  122.     /**
  123.      * The pixels of the image are delivered using one or more calls
  124.      * to the setPixels method.  Each call specifies the location and
  125.      * size of the rectangle of source pixels that are contained in
  126.      * the array of pixels.  The specified ColorModel object should
  127.      * be used to convert the pixels into their corresponding color
  128.      * and alpha components.  Pixel (m,n) is stored in the pixels array
  129.      * at index (n * scansize + m + off).  The pixels delivered using
  130.      * this method are all stored as bytes.
  131.      * @see ColorModel
  132.      */
  133.     void setPixels(int x, int y, int w, int h,
  134.            ColorModel model, byte pixels[], int off, int scansize);
  135.  
  136.     /**
  137.      * The pixels of the image are delivered using one or more calls
  138.      * to the setPixels method.  Each call specifies the location and
  139.      * size of the rectangle of source pixels that are contained in
  140.      * the array of pixels.  The specified ColorModel object should
  141.      * be used to convert the pixels into their corresponding color
  142.      * and alpha components.  Pixel (m,n) is stored in the pixels array
  143.      * at index (n * scansize + m + off).  The pixels delivered using
  144.      * this method are all stored as ints.
  145.      * @see ColorModel
  146.      */
  147.     void setPixels(int x, int y, int w, int h,
  148.            ColorModel model, int pixels[], int off, int scansize);
  149.  
  150.     /**
  151.      * The imageComplete method is called when the ImageProducer is
  152.      * finished delivering all of the pixels that the source image
  153.      * contains, or when a single frame of a multi-frame animation has
  154.      * been completed, or when an error in loading or producing the
  155.      * image has occured.  The ImageConsumer should remove itself from the
  156.      * list of consumers registered with the ImageProducer at this time,
  157.      * unless it is interested in succeeding frames.
  158.      * @see ImageProducer#removeConsumer
  159.      */
  160.     void imageComplete(int status);
  161.  
  162.     /**
  163.      * An error was encountered while producing the image.
  164.      * @see #imageComplete
  165.      */
  166.     int IMAGEERROR = 1;
  167.  
  168.     /**
  169.      * One frame of the image is complete but there are more frames
  170.      * to be delivered.
  171.      * @see #imageComplete
  172.      */
  173.     int SINGLEFRAMEDONE = 2;
  174.  
  175.     /**
  176.      * The image is complete and there are no more pixels or frames
  177.      * to be delivered.
  178.      * @see #imageComplete
  179.      */
  180.     int STATICIMAGEDONE = 3;
  181. }
  182.